import java.util.HashSet;
import java.util.Set;

public class Test {
    public static int singleNumber(int[] nums){
       /* Set<Integer>set=new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else{
                set.remove(nums[i]);
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;*/
        int i=0;
        for(;i<nums.length-1-1;i++){
            nums[i]^=nums[i+1];
        }
        return nums[i];
    }
    public static int numJewelsInStones(String jewels, String stones) {
        int ret=0;
        Set<Character>set=new HashSet<>();
        for (char jewel:jewels.toCharArray()){
            set.add(jewel);
        }
        for (char stone:stones.toCharArray()){
            if(set.contains(stone)){
                ret++;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        int[]arr={2,2,1};
        int ret=singleNumber(arr);
        System.out.println(ret);
        String jewels="ab";
        String stones="asdcbc";
       int ret1= numJewelsInStones(jewels,stones);
        System.out.println(ret1);
    }
}
